]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
AppDisplay: allow changing categories by scrolling over them
authorGiovanni Campagna <gcampagna@src.gnome.org>
Sun, 27 Feb 2011 20:46:17 +0000 (21:46 +0100)
committerGiovanni Campagna <gcampagna@src.gnome.org>
Mon, 28 Feb 2011 21:57:31 +0000 (22:57 +0100)
Respond to scrolling over the app categories by changing them, so
it is not required to point and click, or to use the All view.

https://bugzilla.gnome.org/show_bug.cgi?id=643426

js/ui/appDisplay.js

index ebc19d156e2e348713c18e5cf9d3a8de0ac5d6d5..6fe12f299dc924f1edc97a1297596d004923ce5a 100644 (file)
@@ -109,7 +109,14 @@ ViewByCategories.prototype = {
 
         this._view = new AlphabeticalView();
 
-        this._filters = new St.BoxLayout({ vertical: true });
+        // categories can be -1 (the All view) or 0...n-1, where n
+        // is the number of sections
+        // -2 is a flag to indicate that nothing is selected
+        // (used only before the actor is mapped the first time)
+        this._currentCategory = -2;
+        this._filters = new St.BoxLayout({ vertical: true, reactive: true });
+        this._filters.connect('scroll-event', Lang.bind(this, this._scrollFilter));
+
         this.actor.add(this._view.actor, { expand: true, x_fill: true, y_fill: true });
         this.actor.add(this._filters, { expand: false, y_fill: false, y_align: St.Align.START });
 
@@ -123,7 +130,20 @@ ViewByCategories.prototype = {
         this._sections = [];
     },
 
+    _scrollFilter: function(actor, event) {
+        let direction = event.get_scroll_direction();
+        if (direction == Clutter.ScrollDirection.UP)
+            this._selectCategory(Math.max(this._currentCategory - 1, -1))
+        else if (direction == Clutter.ScrollDirection.DOWN)
+            this._selectCategory(Math.min(this._currentCategory + 1, this._sections.length - 1));
+    },
+
     _selectCategory: function(num) {
+        if (this._currentCategory == num) // nothing to do
+            return;
+
+        this._currentCategory = num;
+
         if (num != -1)
             this._allFilter.remove_style_pseudo_class('selected');
         else